home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / DDEIO.ZIP;1 / IOCTL.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-11-21  |  4.4 KB  |  156 lines

  1. PUBLIC               IOCTL_OUT
  2. PUBLIC               IOCTL_IN
  3. include  extasm.inc
  4. DGROUP               GROUP   _DATA
  5.  
  6. IO_SIZE         equ   32
  7.  
  8. _DATA   SEGMENT PUBLIC  'DATA'
  9.  
  10. ;io_string          db  IO_SIZE dup(0)
  11. io_string          db  '1',0
  12.                    db  14 dup(0)
  13. _DATA   ENDS
  14.  
  15. _TEXT   SEGMENT 'CODE'
  16.              ASSUME cs:_TEXT, ds:DGROUP
  17.  
  18. ;---------------------ioctl_out--------------------------------
  19. ;; This routine is similar the basic IOCTL output routine
  20. ;; called from CLIPPER as IOCTL_OUT(nHandle, szRegisterCommand)
  21.  
  22.  
  23.  
  24. IOCTL_OUT  PROC    FAR
  25.  
  26.              push    bp              ; Save registers
  27.              mov     bp,sp
  28.              push    ds
  29.              push    es
  30.              push    si
  31.              push    di
  32.  
  33.         ;;perform a DOS int 44 to perform ioctl
  34.         ;; deref parms
  35.  
  36.              mov        ax,0
  37.              push       ax  
  38.              call       __parinfo 
  39.              add        sp,2
  40.              cmp        ax, 2
  41.              jnz        io_x
  42.  
  43.         ;; if two parms get the handle as 1, command reg as 2
  44.  
  45.              mov        ax, 1
  46.              push       ax
  47.              call       __parni
  48.              add        sp,2
  49.              push       ax              ; save handle on stack
  50.  
  51.              mov        ax, 2
  52.              push       ax
  53.              call       __parc
  54.              add        sp,2            ; DX:AX has pointer to string
  55.  
  56.              push       ax
  57.              push       dx              ; save on stack
  58.  
  59.              mov        ax, 2
  60.              push       ax
  61.              call       __parclen
  62.              add        sp,2
  63.              mov        cx, ax          ; count of bytes
  64.  
  65.         ;; do it
  66.              pop        ds
  67.              pop        dx              ; ds:dx point at string
  68.  
  69.              pop        bx              ; bx has handle
  70.              mov        ax,4403H        ; ioctl write data
  71.  
  72.              int        21h
  73.             
  74.  
  75. io_x:
  76.              pop     di              ; Restore registers
  77.              pop     si
  78.              pop     es
  79.              pop     ds
  80.              pop     bp
  81.              ret        
  82.  
  83. IOCTL_OUT    ENDP                    ; End of routine
  84.  
  85. ;----------------------------ioctl_in--------------------------------
  86. ;; Read a control string from a device driver
  87. ;; This routine is similar to the BASIC IOCTl$() call
  88. ;; To call from CLIPPER us szString = IOCTL_IN(nHandle)
  89.  
  90. IOCTL_IN     PROC    FAR
  91.  
  92.              push    bp              ; Save registers
  93.              mov     bp,sp
  94.              push    ds
  95.              push    es
  96.              push    si
  97.              push    di
  98.  
  99.         ;; use DOS int 21H IOCTL function 44 to read a control string
  100.  
  101.              mov        ax,0
  102.              push       ax  
  103.              call       __parinfo 
  104.              add        sp,2
  105.              cmp        ax, 1
  106.              jnz        io_xx
  107.  
  108.         ;; if two parms get the handle as 1, command reg as 2
  109.  
  110.              mov        ax, 1
  111.              push       ax
  112.              call       __parni
  113.              add        sp,2
  114.  
  115.              mov        bx, ax          ; handle
  116.              push       ds
  117.              mov        ax, _DATA
  118.              mov        ds, ax
  119.              mov        ax, 4402H       ; read ioctl string
  120.              mov        dx, offset io_string
  121.              mov        cx, IO_SIZE  
  122.  
  123.              int        21H
  124.                                         ; ds:dx has string ax has bytes
  125.              pop        ds
  126.  
  127.              ; try a null terminated
  128.         
  129.              mov        dx, offset io_string
  130.              mov        ax, _DATA
  131.              push       ax              ; segment
  132.              push       dx              ; offset
  133.              call       __retc
  134.              add        sp, 4           ; 3 words
  135.  
  136. ;;             push       ax              ; number of bytes
  137. ;;             mov        ax, DGROUP
  138. ;;             push       ax              ; segment
  139. ;;             push       dx              ; offset
  140. ;;             call       __retclen
  141. ;;             add        sp, 6           ; 3 words
  142. io_xx:
  143.              pop     di              ; Restore registers
  144.              pop     si
  145.              pop     es
  146.              pop     ds
  147.              pop     bp
  148.              ret
  149. IOCTL_IN     ENDP                    ; End of routine
  150.  
  151.  
  152. _TEXT        ENDS                    ; End of code segment
  153.              END
  154.  
  155.  
  156.